<?php

namespace App\Admin\Renderable;

use App\Models\FirmBrand;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class BrandTable extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new FirmBrand(),function (Grid $grid){

            $grid->model()->with(['firm:id,name','profession:id,name','cradle:id,name','location:id,name']);
            $grid->column('id');
            $grid->column('firm.name','所属企业');
            $grid->column('name');
            $grid->column('profession.name','品牌行业');
            $grid->column('cradle.name','品牌发源地');
            $grid->column('location.name','品牌定位');
            $grid->column('created_at');
            $grid->paginate(10);
            $grid->disableActions();
            $grid->showRowSelector();

            $grid->filter(function (Grid\Filter $filter){
                $filter->like('name','品牌名称');
                $filter->like('firm.name','企业名称');
            });
        });
    }
}
